package com.wzh.live.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wzh.live.entity.LiveGoodsEntity;
import com.wzh.live.service.LiveGoodsService;
import com.wzh.common.utils.PageUtils;
import com.wzh.common.utils.R;



/**
 * 
 *
 * @author wzh
 * @email 1281204121@qq.com
 * @date 2022-03-14 14:10:52
 */
@RestController
@RequestMapping("live/livegoods")
public class LiveGoodsController {
    @Autowired
    private LiveGoodsService liveGoodsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = liveGoodsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{goodsId}")
    public R info(@PathVariable("goodsId") Integer goodsId){
		LiveGoodsEntity liveGoods = liveGoodsService.getById(goodsId);

        return R.ok().put("liveGoods", liveGoods);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody LiveGoodsEntity liveGoods){
		liveGoodsService.save(liveGoods);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody LiveGoodsEntity liveGoods){
		liveGoodsService.updateById(liveGoods);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] goodsIds){
		liveGoodsService.removeByIds(Arrays.asList(goodsIds));

        return R.ok();
    }

}
